function [n,names] = plx_event_names(filename)
% plx_event_names(filename): gets the names of event channels in a .plx file
%
% [n, names] = plx_event_names(filename)
%
% INPUT:
%   filename - if empty string, will use File Open dialog
%
% OUTPUT:
%   names - array of event name strings
%   n - number of channels

if nargin ~= 1
    error 'expected 1 input argument';
end

[ filename, isPl2 ] = internalPL2ResolveFilenamePlx( filename );
if isPl2 == 1
    % the code here is only to support legacy scripts with plx_* APIs 
    % when working with .plx and .pl2 files generated by OmniPlex.
    % all .plx files generated by OmniPlex have these 43 hardcoded event names
    n = 43;
    names = 'EVT01';
    for i=2:32
        names = char(names, sprintf('EVT%02d', i));
    end
    names = char(names,'Strobed');
    names = char(names,'Start');
    names = char(names,'Stop');
    for i=1:8
        names = char(names, sprintf('KBD%d', i));
    end
    names = internalPL2TrimNames(names);
    return;
end

[n, names] = mexPlex(16, filename);

end